/**
 * Represents a vertex. This class is an intermediary between the vertex and the heap.
 * @author Erica & Kyle
 *
 */
public class PrimHeapNode implements Comparable {
	//instance fields
	private double label; 
	private Vertex my_vertex;
	private int heap_position;
	private Edge my_min_edge;
	
	//Constructor
	public PrimHeapNode(double some_label, Vertex some_vertex, int some_heap_position) {
		label = some_label;
		my_vertex = some_vertex;
		heap_position = some_heap_position;
	}
	
	/**
	 * Allows PrimHeapNodes to be comparable.
	 * Returns -1 if the incomming object is greater than this objects label
	 * 0 if equal
	 * 1 if the incomming object is less than this object.
	 */
	@Override
	public int compareTo(Object other) {
		int compare = 0; 
		if (other != null) {
			if (other instanceof PrimHeapNode) {
				PrimHeapNode other_prim = (PrimHeapNode) other; 
				if (this.label < other_prim.label) {
					compare = -1;
				} else if (this.label == other_prim.label) {
					compare = 0; 
				} else {
					compare = 1; 
				}
			}
		}
			
		return compare;
	}
	
	@Override
	public boolean equals(Object some_object) {
		Vertex node;
		boolean result = false;
		if(some_object != null) {
			if (some_object instanceof PrimHeapNode) {
				node = (Vertex) some_object;
				if(my_vertex.getName().equals(node.getName())) {
					result = true;
				}
			}
		}
		
		return result;
	}

	//setters and getters
	//*********
	public double getLabel() {
		return label;
	}

	/**
	 * 
	 * 
	 * @param double1
	 * @param some_min_edge
	 */
	public void setLabel(Double double1, Edge some_min_edge) {
		this.label = double1;
		my_min_edge = some_min_edge;
	}

	public Vertex getMy_vertex() {
		return my_vertex;
	}

	public void setMy_vertex(Vertex my_vertex) {
		this.my_vertex = my_vertex;
	}

	public int getHeap_position() {
		return heap_position;
	}

	public void setHeap_position(int heap_position) {
		this.heap_position = heap_position;
	}

	public Edge getMy_min_edge() {
		return my_min_edge;
	}
	//*********
	@Override
	public String toString() {
		String s = label + " " + my_vertex + " " + heap_position + " " + my_min_edge;
		
		return s;
	}
}
